package com.hyh.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.hyh.application.ChatApplication;

/**
 * Created by Administrator on 2019/1/26.
 */

public class SharePreferenceUtil {

    private static SharedPreferences sp;
    public static final String TAG="VideoChat";

    public static class Contact{
        public static final String LocalNumber="LocalNumber";
        public static final String ContactsNumber="ContactsNumber";
        public static final String RecordFlag="RecordFlag";
    }
    private static  SharedPreferences getSharedPreferences(){
        if(sp==null){
            sp = ChatApplication.app.getSharedPreferences(TAG,Context.MODE_PRIVATE);
        }
        return sp;
    }

    public static void save(String key,String value){
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putString(key, value);
        editor.commit();
    }

    public static void save(String key,boolean value){
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    public static String getString(String key){
        return getSharedPreferences().getString(key,null);
    }

    public static Boolean getBoolean(String key){
        return getSharedPreferences().getBoolean(key,false);
    }
}
